package Homework.cms.util;

/**
 * @author ：xx
 * @date ：Created in 2020/6/12 8:35
 * @description：
 * @modified By：
 */
import java.util.List;

public class Page<T> {
    private int totalcount;//数据总量
    private int pagesize=10;
    private int currpage=1;//当前页
    private int currpageindex=0;//当前页索引
    private int totalpage=0;//总页数
    //用来存储当前分页的数据
    private List<T> records=null; //

    public Page(int totalcount,int pagesize,int currpage)
    {
        this.totalcount=totalcount;
        this.pagesize=pagesize;
        this.currpage=currpage;
        this.currpageindex= (currpage-1)*pagesize;
        this.totalpage=this.totalcount%pagesize==0? this.totalcount/pagesize: (this.totalcount/pagesize+1);
    }


    @Override
    public String toString() {
        return "Page [totalcount=" + totalcount + ", pagesize=" + pagesize
                + ", currpage=" + currpage + ", currpageindex=" + currpageindex
                + ", totalpage=" + totalpage + ", records=" + records + "]";
    }


    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    public int getTotalcount() {
        return totalcount;
    }
    public void setTotalcount(int totalcount) {
        this.totalcount = totalcount;
    }
    public int getPagesize() {
        return pagesize;
    }
    public void setPagesize(int pagesize) {
        this.pagesize = pagesize;
    }
    public int getCurrpage() {
        return currpage;
    }
    public void setCurrpage(int currpage) {
        this.currpage = currpage;
    }
    public int getCurrpageindex() {
        return currpageindex;
    }
    public void setCurrpageindex(int currpageindex) {
        this.currpageindex = currpageindex;
    }
    public int getTotalpage() {
        return totalpage;
    }
    public void setTotalpage(int totalpage) {
        this.totalpage = totalpage;
    }
}

